package com.zy.ivideo.controller;

import com.zy.ivideo.entity.BankCardEntity;
import com.zy.ivideo.entity.ResponseEntity;
import com.zy.ivideo.service.BankCardService;
import com.zy.ivideo.token.UserToken;
import com.zy.ivideo.utils.ResponseUtils;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/bankcard")
@Api(value = "银行卡模块API接口", description = "该模块提供银行卡模块服务", tags = "银行卡模块")
public class BankCardController {
    @Autowired
    BankCardService service;

    /**
     * 添加银行卡
     * @param entity
     * @return
     */
    @UserToken
    @ApiOperation(value = "添加银行卡", notes = "添加银行卡", httpMethod = "POST")
    @PostMapping("/addBankCard")
    public ResponseEntity<BankCardEntity> addBankCard(@RequestBody
                                                          @ApiParam(value = "银行卡实体", name = "entity", required = true)
                                                                  BankCardEntity entity){
        return service.addBankCard(entity);
    }

    /**
     * 修改银行卡信息
     * @param entity
     * @return
     */
    @UserToken
    @ApiOperation(value = "修改银行卡信息", notes = "修改银行卡信息", httpMethod = "PUT")
    @PutMapping("/modifyBankCard")
    public ResponseEntity<BankCardEntity> modifyBankCard(@RequestBody
                                                             @ApiParam(value = "银行卡实体", name = "entity", required = true)
                                                                     BankCardEntity entity){
        return service.modifyBankCard(entity);
    }

    /**
     * 删除银行卡
     * @param id
     * @return
     */
    @UserToken
    @ApiOperation(value = "删除银行卡", notes = "删除银行卡", httpMethod = "DELETE")
    @DeleteMapping("/removeBankCard")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "Long", name = "id", value = "银行卡id", required = true),
    })
    public ResponseEntity<Boolean> removeBankCard(Long id){
        return service.removeBankCard(id);
    }

    /**
     * 根据账号id获取银行卡信息
     * @param accountId
     * @return
     */
    @UserToken
    @ApiOperation(value = "根据账号id获取银行卡信息", notes = "根据账号id获取银行卡信息", httpMethod = "GET")
    @GetMapping("/findBankCardByAccountId")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "Long", name = "accountId", value = "账户id", required = true),
    })
    public ResponseEntity<List<BankCardEntity>> findBankCardByAccountId(Long accountId){
        return service.findBankCardByAccountId(accountId);
    }

    /**
     * 根据账号id删除银行卡信息
     * @param accountId 账号id
     * @return
     */
    @UserToken
    @ApiOperation(value = "根据账号id删除银行卡信息", notes = "根据账号id删除银行卡信息", httpMethod = "DELETE")
    @DeleteMapping("/deleteByAccountId")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(dataType = "Long", name = "accountId", value = "账户id", required = true),
    })
    public ResponseEntity<Boolean> deleteByAccountId(Long accountId){
        return service.deleteByAccountId(accountId);
    }
}
